package com.atguigu.tingshu.account.mapper;

import com.atguigu.tingshu.model.account.UserAccount;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;

@Mapper
public interface UserAccountMapper extends BaseMapper<UserAccount> {

    /**
     * 验证且扣减账户余额
     * @param userId 用户ID
     * @param amount 金额
     * @return
     */
    int checkAndDeduct(@Param("userId") Long userId, @Param("amount") BigDecimal amount);


    int add(@Param("userId") Long userId, @Param("amount") BigDecimal amount);
}
